package com.api.shopapi.service.impl;


import com.api.shopapi.entity.Remind;
import com.api.shopapi.entity.dto.RemindDTO;
import com.api.shopapi.mapper.RemindMapper;
import com.api.shopapi.service.RemindService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service("RemindServiceImplOne")
public class RemindServiceImpl implements RemindService {
    @Autowired
    private RemindMapper remindMapper;

    @Override
    public int insert(Remind remind) {
        return remindMapper.insert(remind);
    }

    @Override
    public PageInfo<Remind> getListByUserCode(int pageIndex, int pageSize, String userCode) {
        PageHelper.startPage(pageIndex,pageSize);
        List<Remind> remindList=remindMapper.getListByUserCode(userCode);
        return new PageInfo<>(remindList);
    }

    @Override
    public int update(Remind remind) {
        return remindMapper.update(remind);
    }


    @Override
    public int delete(String remindCode) {
        return remindMapper.delete(remindCode);
    }



    @Override
    public List<Remind> getList() {
        return remindMapper.getList();
    }

    @Override
    public Remind getByRemindCode(String remindCode) {
        return remindMapper.getByRemindCode(remindCode);
    }

    @Override
    public PageInfo<RemindDTO> getPageList(int pageIndex, int pageSize, String governmentCode, Date startTime, Date endTime) {
        PageHelper.startPage(pageIndex,pageSize);
        List<RemindDTO> remindDTOList=remindMapper.getPageList(governmentCode,startTime,endTime);
        return new PageInfo<>(remindDTOList);
    }

}
